package com.webchat.rmi.pgc.mall;


import com.webchat.common.bean.APIResponseBean;
import com.webchat.domain.vo.request.mall.MallProductOperateVO;
import com.webchat.domain.vo.request.mall.MallSPURequestVO;
import com.webchat.domain.vo.response.mall.MallSPUDetailVO;
import com.webchat.rmi.interceptor.RpcRequestInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(name = "webchat-pgc-service",
        contextId = "mallProductClient",
        configuration = RpcRequestInterceptor.class)
public interface MallProductClient {


    /**
     * 商家商品配置
     *
     * @param spuRequest
     * @return
     */
    @PostMapping("/pgc-service/mall/product/save")
    APIResponseBean<Long> save(@RequestBody MallSPURequestVO spuRequest);


    /**
     * 商品上架
     *
     * @param productOperateVO
     * @return
     */
    @PostMapping("/pgc-service/mall/product/publish")
    APIResponseBean<Boolean> publish(@RequestBody MallProductOperateVO productOperateVO);

    /**
     * 商品撤回
     *
     * @param productOperateVO
     * @return
     */
    @PostMapping("/pgc-service/mall/product/invoke")
    APIResponseBean<Boolean> invoke(@RequestBody MallProductOperateVO productOperateVO);

    /**
     * 商品删除
     *
     * @param productOperateVO
     * @return
     */
    @PostMapping("/pgc-service/mall/product/delete")
    APIResponseBean<Boolean> delete(@RequestBody MallProductOperateVO productOperateVO);

    /**
     * 商品详情
     *
     * @param productId
     * @param userId
     * @return
     */
    @GetMapping("/pgc-service/mall/product/detail/{productId}")
    APIResponseBean<MallSPUDetailVO> detail(@PathVariable Long productId,
                                            @RequestParam(required = false) String userId);

    /**
     * 根据SKU查询商品详情
     *
     * @param skuId
     * @return
     */
    @GetMapping("/pgc-service/mall/product/detailBySku/{skuId}")
    APIResponseBean<MallSPUDetailVO> detailBySku(@PathVariable Long skuId);

    /**
     * 根据SKU批量查询商品详情
     *
     * @return
     */
    @PostMapping("/pgc-service/mall/product/batchGet")
    APIResponseBean<Map<Long, MallSPUDetailVO>> batchGetBySku(@RequestBody List<Long> skuIdList);


    /**
     * 批量查询sku对应店铺id
     *
     * @param skuIdList
     * @return
     */
    @PostMapping("/pgc-service/mall/product/batchGetSkuShopId")
    APIResponseBean<Map<Long, Long>> batchGetSkuShopId(@RequestBody List<Long> skuIdList);
}
